package cn.zcx;

import java.util.ArrayList;
import java.util.List;

/**
 * description:根据对象排序
 * author:zcx
 * lenovo
 * 时间：2022.01.25.21.31
 */
public class Lab4 {
    public static void main(String[] args) {
        List<User> list = new ArrayList<>(List.of(new User(42,"Andy",18),new User(600,"张三丰",72),new User(1, "jack", 80), new User(2, "李四", 45), new User(35, "张三", 60), new User(60, "james", 90)));
        System.out.println(list);

        //User a,User b -> a.getScore() - b.getScore()
        list.sort((a, b) -> b.getScore() - a.getScore());
        System.out.println(list);

        //根据姓名升序
        list.sort((a,b)->a.getName().compareTo(b.getName()));
        System.out.println(list);

    }
}
